package com.novunda.platform.web.page;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.FindBys;
import org.openqa.selenium.support.How;
import org.openqa.selenium.support.PageFactory;

/**
 * Represents the page where
 *
 * @author Rob Winch
 */
public class LoginPage extends AbstractPage {


    @FindBy(how = How.NAME, name = "username")
    private WebElement username;

    @FindBy(how = How.NAME, name = "password")
    private WebElement password;

    @FindBy(how = How.CSS, css = "button[type=submit]")
    private WebElement submit;

    public LoginPage(WebDriver driver) {
        super(driver);
    }

    public void login(String username, String password) {
        this.username.sendKeys(username);
        this.password.sendKeys(password);
        this.submit.click();
    }

    public static void login(WebDriver driver) {
        get(driver, "login");
        LoginPage loginPage = PageFactory.initElements(driver, LoginPage.class);
        loginPage.login("admin","123456");
    }

}